package com.geyb.model;

import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import com.geyb.domain.TypeConfig;
/*
 * 01011
 * 
 */
import com.geyb.util.GetSeriesByList;

public class Model1 implements IModel {


	private static final String regex = "^01011+.*?(\\d01011|\\d10100).*";
	@Override
	public String getPredict(List<TypeConfig> tList) {
		String result = "";
		String series = GetSeriesByList.getSeries(tList);
		
		Pattern pattern = Pattern.compile(regex);
		Matcher matcher = pattern.matcher(series);
		if(matcher.find()){
			String temp = matcher.group(1);
			pattern = Pattern.compile("(^0{2,}|^1{2,}).*");
			matcher = pattern.matcher(temp);
			if(matcher.find()){
				result = tList.get(0).getType();
			}else {
				result = tList.get(1).getType();
			}
		}else if (series.startsWith("01011")) {
			result = tList.get(1).getType();
		}
		
		return result;
	}
	
}
